package cn.wolfcode.rbac.service.impl;

import cn.wolfcode.rbac.domain.Customertracehistory;
import cn.wolfcode.rbac.domain.Customertransfer;
import cn.wolfcode.rbac.mapper.CustomertransferMapper;
import cn.wolfcode.rbac.query.QueryObject;
import cn.wolfcode.rbac.service.ICustomertransferService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
public class CustomertransferServiceImpl implements ICustomertransferService {
    @Autowired
    private CustomertransferMapper customertransferMapper;
    @Override
    public PageInfo selectAll(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Customertransfer> list = customertransferMapper.selectAll(qo);
        return new PageInfo(list);
    }

    @Override
    public int turnOver(Customertransfer customertransfer) {
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString  = formatter.format(date);
        customertransfer.setOperate_time(dateString);
        return this.customertransferMapper.turnOver(customertransfer);
    }
}
